import os
import sys


def run(project_dir: str):
    args = sys.argv[3:]
    if len(args) == 0:
        print("generate_stub需要有一个项目启动py文件路径(如server.py)的参数!")
        exit(-1)

    server_py = args[0]

    stub_dir = "stub"
    if len(args) > 1:
        stub_dir = args[1]

    os.system(
        "{exe} {server_py} --generate_stub {stub_dir}".format(
            exe=sys.executable,
            server_py=server_py,
            stub_dir=stub_dir,
        )
    )
